package com.cdream.common.idempotent.autoconfig;

import com.cdream.common.idempotent.aspect.IdempotentAspect;
import com.cdream.common.idempotent.core.AbstractIdempotentStrategy;
import com.cdream.common.lock.core.LockTemplate;
import lombok.AllArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @author : wh
 * @date : 2021/12/30 18:13
 * @description:
 */
@Configuration
@EnableConfigurationProperties({IdempotentProperties.class})
@AllArgsConstructor
public class IdempotentAutoConfiguration {

    private final IdempotentProperties properties;


    @Bean
    public IdempotentAspect idempotentAspect(@Lazy LockTemplate lockTemplate,
                                             @Lazy AbstractIdempotentStrategy idempotentStrategy){
        return new IdempotentAspect(idempotentStrategy,lockTemplate,properties);
    }


}
